package scau.osdesign.service;

import scau.osdesign.model.Fork;
import scau.osdesign.model.Philosopher;

abstract public class Simer extends Thread{
    public static boolean isPaused;
    public abstract void play(Philosopher[] philosophers, Fork[] forks);

    public void waitSelf(){
        try{
            synchronized (this){
                this.wait();
            }
        }catch (InterruptedException e){
            e.printStackTrace();
        }
    }

    public void awakeSelf(){
        synchronized (this){
            this.isPaused = false;
            this.notify();
        }
    }

    public void interruptSelf(){
        synchronized (this){
            this.interrupt();
        }
    }

}
